<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>网站后台管理系统HTML模板--模板之家 www.cssmoban.com</title>
<link href="__static__/admin/css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="__static__/admin/js/jquery.js"></script>

<script type="text/javascript">
$(document).ready(function(){
    $(".click").click(function(){
        $(".tip").fadeIn(200);
    });
    
    $(".tiptop a").click(function(){
        $(".tip").fadeOut(200);
    });

    $(".sure").click(function(){
        var d = {};
        var t = $('#MenuInfo').serializeArray();
        $.each(t, function() {
            d[this.name] = this.value;
        });
        console.log(t)
        if(d.Name=='' || d.Ctrl=='' || d.Alt=='' || d.Pid=='') 
        return alert('请录入完整信息');
        $.post('{:url("addManageMenuInfo")}',{data:d},function(res){
            alert(res.msg)
            if(res.code == 1){
                window.location.reload();
                //$(".tip").fadeOut(100);
            }
        })
        $(".tip").fadeOut(100);
    });

    $(".cancel").click(function(){
        $(".tip").fadeOut(100);
    });

});
</script>


</head>


<body>

	<div class="place">
    <span>位置：</span>
    <ul class="placeul">
    <li><a href="#">首页</a></li>
    <li><a href="#">数据表</a></li>
    <li><a href="#">基本内容</a></li>
    </ul>
    </div>
    
    <div class="rightinfo">
    
    <div class="tools">
    
    	<ul class="toolbar">
        <li class="click"><span><img src="__static__/admin/images/t01.png" /></span>添加</li>
        <!--<li class="click"><span><img src="__static__/admin/images/t02.png" /></span>修改</li>
        <li><span><img src="__static__/admin/images/t03.png" /></span>删除</li>
        <li><span><img src="__static__/admin/images/t04.png" /></span>统计</li>-->
        </ul>
        
        
        <ul class="toolbar1">
        <li><span><img src="__static__/admin/images/t05.png" /></span>设置</li>
        </ul>
    
    </div>
    
    
    <table class="tablelist">
    	<thead>
    	<tr>
            <th>名称<i class="sort"><img src="__static__/admin/images/px.gif" /></i></th>
            <th>排序</th>
            <th>层级</th>
            <th>Ctrl</th>
            <th>ALt</th>
            <th>是否审核</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        {foreach $manage_menu_list as $v}
        <tr>
            <td>{:str_repeat('&nbsp;',$v.Level*2)}|-<input type="text" id="MenuName{$v.id}" value="{$v.Name}"></td>
            <td><input min="0" max="99" type="number" id="MenuSort{$v.id}" value="{$v.Sort}"/></td>
            <td>
                <select id="MenuSuperior{$v.id}">
                    <option value="0" {if $v.Pid EQ 0} selected {/if}>一级菜单</option>
                    {foreach $manage_menu_list as $t}
                    <option value="{$t.id}" {if $v.Pid EQ $t.id} selected {/if}>{:str_repeat('&nbsp;',$t.Level*2)}|-{$t.Name}</option>
                    {/foreach}
                </select>
            </td>
            <td><input type="text" id="MenuCtrl{$v.id}" value="{$v.Ctrl}"/></td>
            <td><input type="text" id="MenuAlt{$v.id}" value="{$v.Alt}"/></td>
            <td>{$v.State|getAllToexamine}</td>
            <td>
                <a href="javascript:;editManageMenuInfo({$v.id})" class="tablelink">修改</a>  
                <a href="javascript:;toexamineManageMenu({$v.id},{$v.State})" class="tablelink">审核</a>    
                <a href="javascript:;deleteManageMenu({$v.id})" class="tablelink"> 删除</a>
            </td>
        </tr> 
        {/foreach}
        </tbody>
    </table>
    
    
    
    </div>
    
    <div class="tip">
        <div class="tiptop"><span>提示信息</span><a></a></div>
        
        <form id="MenuInfo">
            <div class="tipright">
                <p>菜单名称</p><input type="text" id="MenuName" name="Name" style="line-height:30px; background: gray;color: white;"/>
                <p>CTRL名称</p><input type="text" id="MenuCtrl" name="Ctrl" style="line-height:30px; background: gray;color: white;"/>
                <p>ALT名称</p><input type="text" id="MenuAlt" name="Alt" style="line-height:30px; background: gray;color: white;"/>
                <select id="MenuSuperior" name="Pid">
                 <option value="0">一级菜单</option>
                 {foreach $manage_menu_list as $k}
                 <option value="{$k.id}">{:str_repeat('&nbsp;',$k.Level*2)}|-{$k.Name}</option>
                 {/foreach}
                </select>
            </div>
        </form>
        <div class="tipbtn">
            <input name="" type="button"  class="sure" value="确定" />&nbsp;
            <input name="" type="button"  class="cancel" value="取消" />
        </div>
    
    </div>

    <script type="text/javascript">
    function deleteManageMenu(id){
        if(!confirm('确认删除此数据？')) return false;
        $.post('{:url("deleteManageMenu")}',{id:id},function(res){
            console.log('返回数据',res)
            alert(res.msg)
            if(res.code) window.location.reload();
        })
    }
    function toexamineManageMenu(id,sta){
        $.post('{:url("toexamineManageMenu")}',{id:id,sta:sta},function(res){
            console.log('返回数据',res)
            alert(res.msg)
            if(res.code) window.location.reload();
        })
    }
    function editManageMenuInfo(id){
        var nme = $('#MenuName'+id).val();
        var sto = $('#MenuSort'+id).val();
        var sup = $('#MenuSuperior'+id).val();
        var ctrl = $('#MenuCtrl'+id).val();
        var alt = $('#MenuAlt'+id).val();
        if(nme=='' || ctrl=='' || alt=='') return alert('名称/Ctrl/Alt不能为空');
        $.post('{:url("editManageMenuInfo")}',{id:id,nme:nme,sto:sto,sup:sup,ctrl:ctrl,alt:alt},function(res){
            console.log('返回数据',res)
            alert(res.msg)
            if(res.code) window.location.reload();
        })
    }
	</script>
</body>
</html>

